<template>
  <div class="editdata" teleport="body">
    <h4>修改管理员信息</h4>
    <el-form :model="form" label-width="120px">
      <el-form-item label="管理员姓名">
        <el-input v-model="form.adminname" />
      </el-form-item>
      <el-form-item label="管理密码">
        <el-input v-model="form.password" />
      </el-form-item>
      <el-form-item label="管理权限">
        <el-input v-model="form.role" />
      </el-form-item>
      <el-form-item label="密钥">
        <el-input v-model="form.checkedKeys" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">添加</el-button>
        <el-button type="primary" @click="onSubmit">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
  
  <script setup lang="ts">
import { reactive } from "vue";
import service from "../../../utils/service";
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";

const $router = useRouter();
// 声明事件
const emit=defineEmits<{
    (e:"hidden"):void
}>()
interface IAdmin {
  adminname: string;
  role: number;
  password: string;
  checkedKeys: string[];
}
const form = reactive<IAdmin>({
  adminname: "",
  role: 2,
  password: "",
  checkedKeys: [],
});

const onSubmit = () => {
  service({
    url: "/banner/add",
    method: "post",
    data: form,
  }).then((res) => {
    if (res.data.code == 200) {
      ElMessage({
        message: "添加成功！",
        type: "success",
      });
      // $router.push("/Admin/list");
    }
  });
};
</script>
  
  <style scoped>
  .editdata{
    width: 400px;
    height: 300px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    background: #999;
    z-index: 5;
    text-align: center;
  }
  .el-form{
    margin-top: 15px;
  }
  .el-input{
    width: 200px;
  }
  h4{
    margin-top: 10px;
  }
</style>